const loader = require.context("./", false, /\.vue$/);

const pages = [];

for (let key of loader.keys()) {
  let page = loader(key).default;
  //   console.log("page", page);

  let name = page.name.startsWith("page-")
    ? page.name.replace("page-", "")
    : "";
  let path = page.name.startsWith("page-")
    ? page.name.replace("page-", "/").split("-").join("/")
    : "";
  let meta = { title: page.title, nodes: page.nodes, childs: page.childs };
  let component = page;
  if (name && path) {
    // console.log("name-path", name,path)
    pages.push({ name, path, meta, component });
  }
}
// console.log("pages", pages);

export default pages;
